package com.example.teesystem.entityDto;

import com.example.teesystem.common.utils.FileUtil;
import com.example.teesystem.common.utils.TimeUtil;
import com.example.teesystem.entity.User;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.beans.BeanUtils;

/**
 * @author pxr
 * @data 2022/3/29 14:08
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class UserList {
    private Integer id;

    /**
     * 账户名
     */

    private String account;

    /**
     * 性别
     */
    private String gender;

    /**
     * 姓名
     */
    private String myName;

    /**
     * 用户名
     */
    private String username;

    /**
     * 学院
     */
    private String academy;

    private String updateTime;

    private String avatarUrl;

    public UserList(User user){
        BeanUtils.copyProperties(user,this);
        this.updateTime = TimeUtil.dateToString(user.getUpdateTime());
        if(user.getAvatarUrl()!=null && !user.getAvatarUrl().equals("")){
            this.avatarUrl = FileUtil.FILE_PREFIX + user.getAvatarUrl();
        }
    }

}
